home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / raytrace / renaisnc / chaucer.txt < prev    next >
Encoding:
Text File  |  1992-01-04  |  1.6 KB  |  40 lines

  1. This directory contains source code for the sml interpreter.
  2.  
  3. A few tips on extending the interpreter:
  4.  
  5. To add new primitive operators:
  6.  
  7.    -- Write a C procedure that returns an int and accepts no parameters.
  8.       The return value should be TRUE if no errors were encountered, FALSE
  9.       otherwise (someday the return codes can be used to do error recovery,
  10.       etc.).  The procedure receives its operands from the operand stack,
  11.       generally by calling Pop().  See ``stdops.c'' for lots of examples of
  12.       primitive operators.
  13.  
  14.    -- In the file optable.h, list the new procedure as extern, then add an
  15.       entry for it in the PrimitiveTable.
  16.  
  17.  
  18. To add a new primitive data type:
  19.  
  20.    -- Add a new entry to ``enum TokenType'' located in machine.h. New entries
  21.       must be placed just before the NumTokens symbol.
  22.  
  23.    -- Add any necessary data fields to the type ``Token'' (also located in
  24.       machine.h).
  25.  
  26.    -- Write procedures that evaluate, execute, print, free and make copies
  27.       of tokens of the new type.  (Evaluation and execution currently
  28.       differ only in the treatment of CodeBody(s), so you probably only
  29.       have to write a single procedure to perform both of these
  30.       operations.)
  31.  
  32.    -- In methods.h, declare the new procedures external, then enter their
  33.       names in the ``Methods'' table.  The ordering of the rows of the Methods
  34.       table must match the ordering of the symbols in ``enum TokenType.''
  35.  
  36.    -- If the token that you're adding can be stated literally on the input
  37.       stream, then you'll also have to change the scanner and parser (located
  38.       in scanner.l, parser.h, and parser.c).
  39.    
  40.